package 力扣日常刷题.木22一月.第09天0117;

/**
 * @author 帅小伙
 * @date 2022/1/17
 * @description
 */
public class Demo01动态规划困难统计元音字母序列的数目 {


    public int countVowelPermutation(int n) {

        final long MOD = 1000000007;
        long[] dp = new long[5];
        long[] tdp = new long[5];
        for (int i = 0; i < 5; i++) {
            dp[i] = 1;
        }
        for (int i = 1; i < n; i++) {
            tdp[0] = (dp[1]+dp[2]+dp[4])%MOD;
            tdp[1] = (dp[0]+dp[2])%MOD;
            tdp[2] = (dp[1]+dp[3])%MOD;
            tdp[3] = dp[2];
            tdp[4] = (dp[2]+dp[3])%MOD;
            // 复制数组
            System.arraycopy(tdp,0,dp,0,5);
        }


       long ans = 0;
        for (int i = 0; i < 5; i++) {
            ans =(ans+dp[i])%MOD;
        }
        return (int)ans;
    }
}
